#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
void solve()
{
    ll n;
    cin >> n ;
    vector<ll> a(n+1);
    for(ll i=1;i<=n;i++) cin >> a[i];
    for(ll i=1;i<=n;i++)
    {
        a[i] += a[i - 1];
    }
    ll m;
    cin >> m;
    while(m--)
    {
        ll l,r;
        cin >> l >> r;
        cout << a[r] - a[l-1] << endl;
    }
}
int main()
{
    int t = 1;
    // >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
